home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / rbbs_pc / rbbs_asm.zip / ANSI17.ASM < prev    next >
Assembly Source File  |  1988-11-27  |  8KB  |  162 lines

  1. ; ANSI1-7ASM  Revised 11/28/88 Garry G. Kraemer
  2. ;
  3. ;   A problem existed with version 1-6 when the sysop exited to DOS from
  4. ;   CHAT and returned, Linefeeds would not be displayed on the CRT.
  5. ;   The text would overwrite on the same line.  After several hours of
  6. ;   intense debugging, I have placed a few lines of code into the .ASM
  7. ;   file that will add a LineFeed (LF or CHR$(10)) to STRNG$ if it
  8. ;   does not end with one.  I assume that if I find a CR and am NOT at
  9. ;   the end of the string, a LF follows!!
  10. ;
  11. ;   Changed lines reflect GGK in the right column
  12. ;
  13. ;   Garry G. Kraemer    520 El Portal   Merced, CA
  14. ;   WINTONS LOCAL RBBS 9758 N SHAFFER RD WINTON, CA 95388
  15. ;   2400/1200/300 24hrs 400 days a year (209) 358-6154
  16. ;
  17. ; ANSI1-6ASM  Revised 10/28/87 Jon Martin fix boundary bug
  18. ; ANSI1-5ASM  Revised 8/24/85 Dave Terry for QuickBasic Compiler
  19. ; ANSI1-4ASM  Revised 8/23/85 Dave Staehlin
  20.  
  21. ANSI_PRNT SEGMENT PUBLIC 'CODE'         ;By  David W. Terry
  22.           ASSUME CS:ANSI_PRNT           ;    3036 So. Putnam Ct.
  23.           PUBLIC ANSI                   ;    West Valley City, UT 84120
  24.  
  25. ;                      Screen scroll mods by David C. Staehlin
  26. ;                                            5430 Candle Glow NE
  27. ;                                            Albuquerque, NM 87111
  28. ;
  29. ;                                       Data (505) 821-7379 24 Hrs, 2400 Baud
  30. STRG_LEN          DW 0                  ;CHANGED TO LENGTH OF STRING PASSED
  31. VID_PAGE          DB 0                  ;Active video page
  32. ;
  33. ;
  34. ANSI      PROC    FAR
  35.           PUSH    BP
  36.           MOV     BP,SP
  37. ;
  38.           MOV     SI,10[BP]         ;GET STRING DESCRIPTOR
  39.           MOV     BL,[SI+ 2]        ;REARRANGE LOW/HIGH BYTES
  40.           MOV     BH,[SI+ 3]        ;NOW BX HOLDS THE ADDRESS OF THE STRING
  41.           MOV     AX,[SI]           ;GET STRING LENGTH
  42.           ADD     AX,BX             ;ADD INITIAL OFFSET (BX) TO LENGTH
  43.           MOV     STRG_LEN,AX       ;STORE OFFSET PLUS LENGTH
  44. ;
  45.           PUSH    BX                ;SAVE BX
  46.           MOV     AH,15             ;Get current video state
  47.           INT     10H               ;DO INTERRUPT
  48.           MOV     VID_PAGE,BH       ;Save it
  49.           POP     BX                ;RESTORE BX
  50. ;
  51.           MOV     AH,02             ;SET UP FOR FUNCTION CALL 02H
  52. LOOP:
  53.           MOV     DL,[BX]           ;SET DL TO CHARACTER TO PRINT
  54.           PUSH    DX                ;Save the character in AX 'till we check..
  55.           CALL    WHERE_ARE_WE      ; where the cursor is.......
  56.           CMP     DH,17H            ;Row 24?
  57.           JL      NOPE              ; Jump if less......
  58.           CMP     DX,174FH          ;Row 24 column 79 ?
  59.           JZ     NEXT1              ;YES, JUMP TO NEXT 1
  60.           CMP     DH,18H            ;Row 25?
  61.           JZ      NOPE              ;Don't scroll line 25
  62. ;         DEC     BX                ; Else backup one character
  63. ;         JMP     SCROLL2           ; And go scroll the screen
  64. ;
  65. ; program never executes thru NEXT2!!  Trust ME!                            GGK
  66. ;
  67. NEXT2:    POP     DX                ;And restore the stack to where it was
  68.           CMP     DL,0AH            ;Do we have a line feed?
  69.           JZ      SCROLL            ; Yup - scroll this sucker!
  70.           CMP     DL,0DH            ;  How about a carriage return?
  71.           JNZ     NOPE1             ;  Nope - just go display it.......
  72.           INC     BX                ;  Yup - see if next char is a line feed
  73.           MOV     DX,[BX]
  74.           CMP     DL,0AH            ;  Well, is it?
  75.           JZ      SCROLL            ;  It sure is - let's go scroll
  76.           DEC     BX                ;  Oops - just a carriage return
  77.           JMP     SCROLL            ;  But let's go scroll it anyway
  78. ;
  79. NEXT1:    POP     DX                ; save DX
  80.           INT     21H               ; print char using interrupt
  81.           CALL SCROLLIT
  82.           JMP     EXIT1
  83. ;
  84. NOPE:     POP     DX
  85. NOPE1:    INT     21H               ;Else just display it
  86. SKIPIT:   INC     BX                ; point to next char
  87.           CMP     DL,0DH            ; WAS LAST CHAR A CR?                   GGK
  88.           JNZ     NOTCR             ; NO, jump to not CR                    GGK
  89.           CMP     BX, STRG_LEN      ; AT END OF STRING?                     GGK
  90.           JB      LOOP              ; NO, CONTINUE - NEXT MUST BE A LF!!    GGK
  91.           MOV     DL,0AH            ; ELSE AT END OF STRING SO WE ADD A LF! GGK
  92.           INT     21H               ; DO INTERRUPT AND DISPLAY IT!          GGK
  93.           JMP     EXIT1             ; AND EXIT                              GGK
  94. ;                                                                           GGK
  95. ;                                                                           GGK
  96. NOTCR:    CMP     BX,STRG_LEN       ; Test 'AT END OF STRING' ?             GGK
  97.           JB      LOOP              ; NO, LOOP UNTIL ALL CHARS PROCESSED
  98. ;
  99. EXIT1:    MOV     AH,03             ;SET UP FOR ROM-BIOS CALL (03H)
  100.           MOV     BH,VID_PAGE       ;TO READ THE CURRENT CURSOR POSITION
  101.           INT     10H               ;  DH = ROW   DL = COLUMN
  102.           INC     DH                ;ADD 1 TO ROW (BECAUSE TOP OF SCREEN = 0)
  103.           INC     DL                ;ADD 1 TO COL (BECAUSE POS 1 = 0)
  104. ;
  105.           MOV     SI,[BP]+ 8
  106.           MOV     [SI],DH           ;PASS BACK ROW COORDINATE
  107.           MOV     SI,[BP]+ 6
  108.           MOV     [SI],DL           ;PASS BACK COLUMN COORDINATE
  109. ;
  110.           POP     BP
  111.           RET     6
  112. ANSI      ENDP
  113.  
  114. Where_Are_We:                       ;Get the current cursor position
  115.           PUSH    AX                ;Save the registers
  116.           PUSH    BX
  117.           PUSH    CX
  118.           MOV     AH,03             ;SET UP FOR ROM-BIOS CALL (03H)
  119.           MOV     BH,VID_PAGE       ;TO READ THE CURRENT CURSOR POSITION
  120.           INT     10H               ;  DH = ROW   DL = COLUMN
  121.           POP     CX                ;Restore the registers
  122.           POP     BX
  123.           POP     AX
  124.           RET                        ;And go back from wence we came
  125. ;
  126. SCROLL2:  POP     DX                ;Put the stack like it was
  127. SCROLL:   CALL    SCROLLIT          ;Scroll the screen
  128.           JMP     SKIPIT
  129. ;
  130. SCROLLIT: PUSH    AX                ;Save the registers that will be affected
  131.           PUSH    BX
  132.           PUSH    CX
  133.           PUSH    DX
  134.           PUSH    BP
  135.           MOV     AH,2              ;Now set cursor position to 24,0
  136.           MOV     DX,1700H          ;so we can get the proper character
  137.           MOV     BH,VID_PAGE       ;attribute
  138.           INT     10H
  139.           MOV     AH,8              ;Get the current character attribute
  140.           MOV     BH,VID_PAGE
  141.           INT     10H
  142.           MOV     BH,AH             ;Transfer the attribute to BH for next call
  143.           MOV     AH,6              ;Otherwise scroll 24 lines
  144.           MOV     AL,1              ; Only blank line 24
  145.           MOV     CX,0000H          ; Begin scroll at position 0,0
  146.           MOV     DX,174FH          ; End scroll at Line 24, Col 79
  147.           INT     10H               ; And do it.......
  148.           MOV     AH,2              ;Now set cursor position to 24,0
  149.           MOV     DX,1700H
  150.           MOV     BH,VID_PAGE
  151.           INT     10H
  152.           POP     BP
  153.           POP     DX                ;Restore the stack like it was
  154.           POP     CX
  155.           POP     BX
  156.           POP     AX
  157.           RET
  158. ;
  159. ANSI_PRNT ENDS
  160.           END
  161. 
  162.